Skip to content

feat: light/dark mode via Codex token mapping - #2

Merged
alistair3149 merged 5 commits into
mainfrom
feat/dark-mode
Jun 2, 2026
Merged

alistair3149 merged 5 commits into
mainfrom
feat/dark-mode

Conversation

@alistair3149

Copy link
Copy Markdown
Member

Summary

Make AGGrid grids follow the wiki's light/dark/OS colour scheme (and skin/wiki colour customisations) by mapping AG Grid 35's theme colour params to Codex design tokens (CSS variables). The grid tracks the wiki theme purely through the CSS cascade — no JS theme-syncing, no data-ag-theme-mode.

How it works

  • A single theme is built from themeQuartz.withParams(...) whose colour params reference Codex tokens, e.g. backgroundColor: 'var(--background-color-base, #fff)'. Light fallbacks keep non-Codex skins rendering a usable light grid.
  • browserColorScheme: 'inherit' is set so AG Grid's wrapper doesn't pin color-scheme to light — letting light-dark() colour tokens resolve to the page's current mode inside the grid. .ext-aggrid also declares color-scheme: inherit.
  • mountGrid applies the theme only when the config has no theme, leaving a caller-provided theme untouched.
  • Colours only (Codex exposes only colour tokens as CSS variables); typography inherits the page font.

Client-side only — no PHP/Lua changes.

Testing

  • Vitest: 12 tests (theme param shape, memoisation, browserColorScheme, theme-applied-vs-preserved, double-mount guard). npm run lint clean.
  • Browser (Citizen): verified the grid background resolves dark in night mode and light in day mode via the wiki theme toggle, legible in both.

🤖 Generated with Claude Code

alistair3149 and others added 5 commits June 2, 2026 01:55
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AG Grid's themeQuartz defaults browserColorScheme to "light", emitting
color-scheme: light on .ag-root-wrapper, which pinned Citizen's light-dark()
Codex tokens to their light values inside the grid. Set browserColorScheme:
'inherit' so the wrapper inherits the page scheme. Verified: the grid background
flips dark (night) / light (day) with the wiki theme toggle.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Refer to light-dark() color tokens / the page's mode rather than naming a
specific skin.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
color-scheme is an inherited property, so .ext-aggrid already takes the page
scheme from its ancestors. The grid's scheme is governed by the theme's
browserColorScheme: 'inherit' (which controls .ag-root-wrapper). Verified the
grid still flips dark/light with the rule removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alistair3149
alistair3149 merged commit be4d20a into main Jun 2, 2026
9 checks passed
@alistair3149
alistair3149 deleted the feat/dark-mode branch June 2, 2026 06:09
@alistair3149 alistair3149 mentioned this pull request Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant